package com.geekaca.jdbc;

import java.sql.*;

public class Demo1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        // 加载驱动
        Class.forName("com.mysql.jdbc.Driver");

        String url = "jdbc:mysql://127.0.0.1:3306/dbemp?useSSL=false&characterEncoding=utf8";
        String username = "root";
        String password = "123456";

        Connection connection = DriverManager.getConnection(url, username, password);
        String sql = "select * from dongtu_emp";

        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
//        System.out.println(resultSet);
        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            int salary = resultSet.getInt("salary");
            System.out.println(id + " " + name + " " + salary);

        }
        resultSet.close();
        statement.close();
        connection.close();

    }
}
